package com.carlinfo.stu_ques.question.pojo;

import java.util.Date;

import com.carlinfo.stu_ques.common.util.DateUtil;

import com.carlinfo.stu_ques.users.pojo.Students;

/**
 * 属性:id,学生id,答案,是否正确,创建时间,结束时间
 */
public class Answer
{
	private int id;
	/* 关联字段 */
	private int questionId;
	private int studentId;
	private String jieGuo;
	private boolean shiFou;
	private Date createTime;
	private Date endTime;
	/* 关联关系 */
	private Question question;
	private Students students;

	public void setQuestion(Question question)
	{
		this.question = question;
	}

	public Question getQuestion()
	{
		return question;
	}

	public int getId()
	{
		return id;
	}

	public void setId(int id)
	{
		this.id = id;
	}

	public int getStudentId()
	{
		return studentId;
	}

	public void setStudentId(int studentId)
	{
		this.studentId = studentId;
	}

	public String getJieGuo()
	{
		return jieGuo;
	}

	public void setJieGuo(String jieGuo)
	{
		this.jieGuo = jieGuo;
	}

	public boolean isShiFou()
	{
		return shiFou;
	}

	public void setShiFou(boolean shiFou)
	{
		this.shiFou = shiFou;
	}

	public Date getCreateTime()
	{
		return createTime;
	}

	public void setCreateTime(Date createTime)
	{
		this.createTime = createTime;
	}

	public Date getEndTime()
	{
		return endTime;
	}

	public void setEndTime(Date endTime)
	{
		this.endTime = endTime;
	}

	public String toString()
	{
		String quesName = "无";
		/* 防止空指针 */
		if (this.question != null)
		{
			quesName = this.question.getName();
			if (quesName.length() >= 3)
			{
				quesName = quesName.substring(0, 3) + "...";
			}
		}
		String stuName = "无";
		if (this.students != null)
		{
			stuName = this.students.getName();
		}
		DateUtil dateUtil = new DateUtil();
		String result = getId() + "\t" + quesName + "\t" + stuName + "\t" + getJieGuo() + "\t"
				+ (isShiFou() ? "正确" : "错误") + "\t" + dateUtil.dateTimeToStr(getCreateTime()) + "\t"
				+ dateUtil.dateTimeToStr(getEndTime());
		return result;
	}

	public int getQuestionId()
	{
		return questionId;
	}

	public void setQuestionId(int questionId)
	{
		this.questionId = questionId;
	}

	public Students getStudents()
	{
		return students;
	}

	public void setStudents(Students students)
	{
		this.students = students;
	}

}
